package bcMedTests;

import java.sql.Date;

import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import bcMedBeans.*;
import bcMedEntity.EntityDataBase;
import bcMedEntity.EntityDataBaseRead;

public class TestEntityDataBaseRead {

	EntityDataBase testeDb;
	
	@BeforeClass
	public void setUp() {
		testeDb = new EntityDataBase();
	}
	
	@Test
	public void testDrivePresente() {
		assert testeDb.isDriverPresent();
	}
	
	
	
	@Test
	public void testReadEndereco() {
		int id=1;
		testeDb.connectDataBase();
		EntityDataBaseRead dbRead = new EntityDataBaseRead(testeDb);
		Endereco enderecoTeste = dbRead.readEndereco(id);
		boolean c01 = enderecoTeste.getRua().equals("rua a");
		boolean c02 = enderecoTeste.getCep().equals("12200-200");
		boolean c03 = enderecoTeste.getEstado().equals("sao paulo");
		assert (c01 && c02 && c03);
	}
	
	
	
	@Test
	public void testReadPlanoSaude() {
		int id=1;
		testeDb.connectDataBase();
		EntityDataBaseRead dbRead = new EntityDataBaseRead(testeDb);
		PlanoSaude planoTeste = dbRead.readPlanoSaude(id);
		assert planoTeste.getNome().equals("unimed");
	}
	
	
	
	@Test
	public void testReadStatusConsulta() {
		int id=1;
		testeDb.connectDataBase();
		EntityDataBaseRead dbRead = new EntityDataBaseRead(testeDb);
		StatusConsulta statusConsultaTeste = dbRead.readStatusConsulta(id);
		assert statusConsultaTeste.getNome().equals("agendado");
	}
	
	
	
	@Test
	public void testReadTipoConsulta() {
		int id=1;
		testeDb.connectDataBase();
		EntityDataBaseRead dbRead = new EntityDataBaseRead(testeDb);
		TipoConsulta tipoConsultaTeste = dbRead.readTipoConsulta(id);
		assert tipoConsultaTeste.getNome().equals("Procedimento A");
	}
	
	@Test
	public void testReadConsulta() {
		int id=1;
		testeDb.connectDataBase();
		EntityDataBaseRead dbRead = new EntityDataBaseRead(testeDb);
		Consulta consultaTeste = dbRead.readConsulta(id);
		assert consultaTeste.getData().equals(new Date(110, 4, 10));
		assert consultaTeste.getMedico().getIdMedico()==1;
		assert consultaTeste.getPaciente().getIdPaciente()==1;
		assert consultaTeste.getStatusConsulta().getIdStatusConsulta()==4;
		assert consultaTeste.getTipoConsulta().getIdTipoConsulta()==1;
		
	}
	
	@Test
	public void testReadMedico() {
		int id=1;
		testeDb.connectDataBase();
		EntityDataBaseRead dbRead = new EntityDataBaseRead(testeDb);
		Medico mt = dbRead.readMedico(id);
		assert mt.getNome().equals("Medico A");	
	}
	
	@Test
	public void testReadPaciente() {
		int id=1;
		testeDb.connectDataBase();
		EntityDataBaseRead dbRead = new EntityDataBaseRead(testeDb);
		Paciente pt = dbRead.readPaciente(id);
		assert pt.getNome().equals("Nome A da Silva");
		assert pt.getCadastro().equals(new Date(110, 4, 10));
		assert (pt.getIdade()==33);
		assert pt.getSexo()=='m';
		assert pt.getPlanoSaude().getIdPlanoSaude()==1;
		assert pt.getEndereco().getIdEndereco()==1;
	}
	
	
	
	
	
}
